package com.cy.springcolud.entities;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> {

	private Integer code;
	private String message;
	private T data;

	public CommonResult<T> success(T data) {
		CommonResult responseResult = new CommonResult();
		responseResult.setCode(200);
		responseResult.setMessage("成功");
		responseResult.setData(data);
		return responseResult;
	}

	public CommonResult<T> fail(T data) {
		CommonResult responseResult = new CommonResult();
		responseResult.setCode(500);
		responseResult.setMessage("失败");
		responseResult.setData(data);
		return responseResult;
	}

	/*public CommonResult(Integer code,String message){
		this(code,message,null);
//		this.code=code;
//		this.message=message;
//		this.data=null;
	}*/

}
